﻿using System;
using System.Globalization;
using System.Xml.Serialization;

namespace QuickDev.Model
{
    [Serializable()]
    public class SiteSettings
    {
        #region Constants

        public const string SITESETTINGS = "siteSettings";

        #endregion

        #region Member Variables
        private string _analytics;
        private string _language;
        private string _currency;
        private string _theme;
        private string _siteName;
        private bool _requireSsl = true;
        private string _tagLine;
        CultureInfo _cultureInfo;
        private string _siteLogo;
        private string _newsFeedUrl;
        private string _domain;
        private string _url;
        private bool _useCaching = false;
        private int _shortCacheSeconds = 120;  //2 minutes
        private int _normalCacheSeconds = 300; //5 minutes
        private int _longCacheSeconds = 1500;  // 25 minutes
        private bool _generateThumbs = true;
        private int _thumbSmallWidth = 150;
        private int _thumbSmallHeight = 150;

        private int _systemThumbnailWidth = 90;
        private int _systemThumbnailHeight = 45;

        private int _maxAges = 60;

        private string _broadcast;

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the site logo.
        /// </summary>
        /// <value>The site logo.</value>
        public string SiteLogo
        {
            get
            {
                return _siteLogo;
            }
            set
            {
                _siteLogo = value;
            }
        }

        /// <summary>
        /// Gets or sets the name of the site.
        /// </summary>
        /// <value>The name of the site.</value>
        public string SiteName
        {
            get
            {
                return _siteName;
            }
            set
            {
                _siteName = value;
            }
        }

        /// <summary>
        /// Gets or sets the domain of the site.
        /// </summary>
        /// <value>The domain of the site.</value>
        public string Domain
        {
            get
            {
                return _domain;
            }
            set
            {
                _domain = value;
            }
        }

        /// <summary>
        /// Gets or sets the Url of the site.
        /// </summary>
        /// <value>The Url of the site.</value>
        public string Url
        {
            get
            {
                return _url;
            }
            set
            {
                _url = value;
            }
        }

        /// <summary>
        /// Gets or sets the analytics.
        /// </summary>
        /// <value>The analytics.</value>
        public string Analytics
        {
            get
            {
                return _analytics;
            }
            set
            {
                _analytics = value;
            }
        }

        /// <summary>
        /// Gets or sets the tag line.
        /// </summary>
        /// <value>The tag line.</value>
        public string TagLine
        {
            get
            {
                return _tagLine;
            }
            set
            {
                _tagLine = value;
            }
        }

        /// <summary>
        /// Gets or sets the news feed URL.
        /// </summary>
        /// <value>The news feed URL.</value>
        public string NewsFeedUrl
        {
            get
            {
                return _newsFeedUrl;
            }
            set
            {
                _newsFeedUrl = value;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [require SSL].
        /// </summary>
        /// <value><c>true</c> if [require SSL]; otherwise, <c>false</c>.</value>
        public bool RequireSsl
        {
            get
            {
                return _requireSsl;
            }
            set
            {
                _requireSsl = value;
            }
        }

        /// <summary>
        /// Gets or sets the language.
        /// </summary>
        /// <value>The language.</value>
        public string Language
        {
            get
            {
                return _language;
            }
            set
            {
                _language = value;
            }
        }

        /// <summary>
        /// Gets or sets the currency code.
        /// </summary>
        /// <value>The currency code.</value>
        public string CurrencyCode
        {
            get
            {
                return _currency;
            }
            set
            {
                _currency = value;
            }
        }

        /// <summary>
        /// Gets or sets the theme.
        /// </summary>
        /// <value>The theme.</value>
        public string Theme
        {
            get
            {
                return _theme;
            }
            set
            {
                _theme = value;
            }
        }

        /// <summary>
        /// Gets the currency symbol.
        /// </summary>
        /// <value>The currency symbol.</value>
        [XmlIgnore]
        public string CurrencySymbol
        {
            get
            {
                if ( _cultureInfo == null )
                {
                    _cultureInfo = new CultureInfo( this.Language );
                }
                return _cultureInfo.NumberFormat.CurrencySymbol;
            }
        }

        /// <summary>
        /// Gets the currency decimals.
        /// </summary>
        /// <value>The currency decimals.</value>
        [XmlIgnore]
        public int CurrencyDecimals
        {
            get
            {
                if ( _cultureInfo == null )
                {
                    _cultureInfo = new CultureInfo( this.Language );
                }
                return _cultureInfo.NumberFormat.CurrencyDecimalDigits;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether the site should use caching.
        /// </summary>
        /// <value><c>true</c> if [use caching]; otherwise, <c>false</c>.</value>
        public bool UseCaching
        {
            get { return _useCaching; }
            set { _useCaching = value; }
        }

        /// <summary>
        /// Gets or sets the short cache seconds.
        /// </summary>
        /// <value>The short cache seconds.</value>
        public int ShortCacheSeconds
        {
            get { return _shortCacheSeconds; }
            set { _shortCacheSeconds = value; }
        }

        /// <summary>
        /// Gets or sets the normal cache seconds.
        /// </summary>
        /// <value>The normal cache seconds.</value>
        public int NormalCacheSeconds
        {
            get { return _normalCacheSeconds; }
            set { _normalCacheSeconds = value; }
        }

        /// <summary>
        /// Gets or sets the long cache seconds.
        /// </summary>
        /// <value>The long cache seconds.</value>
        public int LongCacheSeconds
        {
            get { return _longCacheSeconds; }
            set { _longCacheSeconds = value; }
        }

        /// <summary>
        /// Gets or sets the value if the imagehandler should generate tumbs.
        /// </summary>
        /// <value><c>true</c> if [generate thumbs]; otherwise, <c>false</c>.</value>
        public bool GenerateThumbs
        {
            get
            {
                return _generateThumbs;
            }
            set
            {
                _generateThumbs = value;
            }
        }

        /// <summary>
        /// Gets or sets the width of the small thumbs.
        /// </summary>
        /// <value>The width of the thumb small.</value>
        public int ThumbSmallWidth
        {
            get
            {
                return _thumbSmallWidth;
            }
            set
            {
                _thumbSmallWidth = value;
            }
        }

        /// <summary>
        /// Gets or sets the height of the small thumbs.
        /// </summary>
        /// <value>The height of the thumb small.</value>
        public int ThumbSmallHeight
        {
            get
            {
                return _thumbSmallHeight;
            }
            set
            {
                _thumbSmallHeight = value;
            }
        }

        /// <summary>
        /// Gets or sets the height of the small thumbs.
        /// </summary>
        /// <value>The height of the thumb small.</value>
        public int SystemThumbnailHeight
        {
            get
            {
                return _systemThumbnailHeight;
            }
            set
            {
                _systemThumbnailHeight = value;
            }
        }

        /// <summary>
        /// Gets or sets the width of the small thumbs.
        /// </summary>
        /// <value>The width of the thumb small.</value>
        public int SystemThumbnailWidth
        {
            get
            {
                return _systemThumbnailWidth;
            }
            set
            {
                _systemThumbnailWidth = value;
            }
        }

        /// <summary>
        /// Gets or sets the Broadcast.
        /// </summary>
        /// <value>The Broadcast.</value>
        public string Broadcast
        {
            get
            {
                return _broadcast;
            }
            set
            {
                _broadcast = value;
            }
        }

        /// <summary>
        /// Gets or sets the short Maximum Ages.
        /// </summary>
        /// <value>The short Maximum Ages.</value>
        public int MaximumReturnOrderItems
        {
            get { return _maxAges; }
            set { _maxAges = value; }
        }

        #endregion
    }
}